package com.cqut.controller;


import com.cqut.VO.result.ResultVO;
import com.cqut.VO.checkTask.CheckTaskListVO;
import com.cqut.service.CheckTaskService;
import com.cqut.util.ResultVOUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 批阅作业 前端控制器
 * </p>
 *
 * @author 冯永龙
 * @since 2021-06-15
 */
@RestController
@RequestMapping("//checkTask")
public class CheckTaskController {
    @Autowired
    private CheckTaskService checkTaskService;

    @GetMapping("/getTaskList/{taskId}")
    public ResultVO<CheckTaskListVO> getCheckTaskList(@PathVariable("taskId") String taskId) {
        List<CheckTaskListVO> checkTaskList = checkTaskService.getCheckTaskList(taskId);
        if (checkTaskList != null) {
            return ResultVOUtil.success(checkTaskList);
        }
        return ResultVOUtil.fail();
    }

    @GetMapping("/giveScore/{taskId}/{userId}/{score}")
    public ResultVO<Object> giveTaskScore(
            @PathVariable("taskId") String taskId,
            @PathVariable("userId") Integer userId,
            @PathVariable("score") String score) {
        if (checkTaskService.giveTaskScore(taskId, userId, score)) {
            return ResultVOUtil.success(null);
        }
        return ResultVOUtil.fail();
    }

}

